package cn.cheegon.blog.controller;

import cn.cheegon.blog.common.api.CommonResult;
import cn.cheegon.blog.service.FileService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Desc:
 * @Author: cheegon
 * @Date: Create in 2024/6/26  上午10:23
 */
@Slf4j
@RestController
@RequestMapping("/file/*")
public class FileController {
    @Autowired
    FileService fileService;

    @PostMapping("upload/image")
    public CommonResult<String> uploadImage(@RequestParam("file") MultipartFile file) {
        return CommonResult.success(fileService.uploadImage(file));
    }

    @PostMapping("file")
    public String upload() {

        return "upload";
    }
}
